﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Xml;
using TomanuExtensions.Utils;

namespace AmiEmuLib.AmigaConfiguration.FloppiesConfig
{
    /// <summary>
    /// Floppied settings. Masimum four floppies can be connected to amiga.
    /// </summary>
    public class Floppies : XmlBase
    {
        /// <summary>
        /// List of floppies.
        /// </summary>
        public List<Floppy> List = new List<Floppy>();

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="a_reader"></param>
        public Floppies(XmlReader a_reader)
            : base(a_reader)
        {
        }

        protected override void ReadXml(XmlReader a_reader)
        {
            List.Clear();

            a_reader.ReadStartElement(GetType().Name);

            while (a_reader.IsStartElement())
                List.Add(new Floppy(a_reader));

            a_reader.ReadEndElement();
        }

        public override void WriteXml(XmlWriter a_writer)
        {
            a_writer.WriteStartElement(GetType().Name);

            foreach (var floppy in List)
                floppy.WriteXml(a_writer);

            a_writer.WriteEndElement();
        }
    }
}
